package insight.google.game.era.data;

import insight.google.game.era.bo.GameUser;
import insight.google.game.era.bo.policy.AbstractPolicy;
import insight.google.game.era.bo.policy.PolicyFactory;
import insight.google.game.era.bo.policy.character.CharacterPolicy;
import insight.google.game.era.data.policys.Policy;
import org.directwebremoting.annotations.RemoteProperty;

import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.directwebremoting.annotations.DataTransferObject;

import com.google.appengine.api.datastore.Key;

/**
 * Card Class.
 * @author MMC
 *
 */
@DataTransferObject
public class Card extends BaseData {
	public static enum COLOR {
		RED("color.red"),BLACK("color.black");
		private String name;
		private COLOR(String name) {
			this.name = name;
		}
		public String toString() {
			return name;
		}
	};
	
	public static enum SUITE {
		SPADE("suite.spade"), HEART("suite.heart"),	CLUB("suite.club"),	DIAMOND("suite.diamond");
		
		private String name;
		private SUITE(String name) {
			this.name = name;
		}
		public String toString() {
			return name;
		}		
	};
	
	public static enum RANK {
		AA("A"), A2("2"),A3("3"), A4("4"),A5("5"), A6("6"),A7("7"), A8("8"),A9("9"), A10("10"),
		AJ("J"), AQ("Q"),AK("K"),ABJ("Big Joker"), ALJ("Little Joker");
		
		private String name;
		private RANK(String name) {
			this.name = name;
		}
		public String toString() {
			return name;
		}		
	};
	
	public static enum TYPE {
		KITS("type.kits"), WEAPON("type.weapon"), ARMOR("type.armor"), MOVER("type.mover"), ACTION("type.action");
		
		private String name;
		private TYPE(String name) {
			this.name = name;
		}
		public String toString() {
			return name;
		}		
	};
	
	@RemoteProperty
	protected String id;
	
	@RemoteProperty
	protected String name;
	@RemoteProperty
	protected String type;
	@RemoteProperty
	protected String color;
	@RemoteProperty
	protected String suite;
	@RemoteProperty
	protected String rank;

	protected int range;

	@Persistent
	protected List<Integer> policyList = new ArrayList<Integer>(); 
	
	public static final String GAME_CARD = "GAME_CARD";
	
	public Card(){
		
	}
	
	public Card(String id, String name, String type, String color, String suite, String rank, List<Integer> policyList) {
//		this.id = id;
		this.name = name;
		this.type = type;
		this.color = color;
		this.suite = suite;
		this.rank = rank;
		this.policyList = policyList;
	}
	
	/**
	 * @return the id
	 */
	@RemoteProperty
	public String getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	@RemoteProperty
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the policyList
	 */
	@RemoteProperty
	public List<Integer> getPolicyList() {
		return policyList;
	}

	@RemoteProperty
	public List<Policy> getClientPolicyList() {
		List<Policy> clientPolicyList = new ArrayList<Policy>();
		for(Integer policyId : policyList){
			Policy policy = PolicyFactory.getInstance(policyId);
			clientPolicyList.add(policy);
		}
		return clientPolicyList;
	}
	/**
	 * @param policyList the policyList to set
	 */
	public void setPolicyList(List<Integer> policyList) {
		this.policyList = policyList;
	}
	/**
	 * @return the type
	 */
	@RemoteProperty
	public String getType() {
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}
	/**
	 * @return the color
	 */
	@RemoteProperty
	public String getColor() {
		return color;
	}
	/**
	 * @param color the color to set
	 */
	public void setColor(String color) {
		this.color = color;
	}
	/**
	 * @return the suite
	 */
	@RemoteProperty
	public String getSuite() {
		return suite;
	}
	/**
	 * @param suite the suite to set
	 */
	public void setSuite(String suite) {
		this.suite = suite;
	}
	/**
	 * @return the rank
	 */
	@RemoteProperty
	public String getRank() {
		return rank;
	}
	/**
	 * @param rank the rank to set
	 */
	public void setRank(String rank) {
		this.rank = rank;
	}
	/**
	 * @return the range
	 */
	public int getRange() {
		return range;
	}
	/**
	 * @param range the range to set
	 */
	public void setRange(int range) {
		this.range = range;
	}
}
